package ws.jonas.sybosc.model;

public class Average {
	private long sum;
	private int count;

	public Average() {
		this(0, 0);
	}

	public Average(long value) {
		this(value, 1);
	}

	private Average(long sum, int count) {
		this.sum = sum;
		this.count = count;
	}

	public void add(long value) {
		sum += value;
		++count;
	}

	public double average() {
		return count != 0 ? ((double) sum) / count : 0;
	}
}
